# -*- coding: utf-8 -*-
# @Time     : 2021/11/26 10:41
# @Author   : Aries
# @File     : 有参装饰器.py
# @Describe : 
# @Software : PyCharm

def level(num):

    def decorator(func):
        def inner(*args, **kwargs):
            if num == 1:
                print("权限1验证成功...")
                print("获得登录index页面的权限...")
                return func(*args, **kwargs)
            elif num == 2:
                print("权限2验证成功...")
                print("获得登录商品详情页的权限...")
                return func(*args, **kwargs)
            else:
                raise ValueError("请输入正确的权限验证级别参数：1 or 2")
        return inner
    return decorator


@level(2)
def login(username, pwd):
    if username == "admin" and pwd == "123456":
        return "login success"

    return "login failure"

if __name__ == '__main__':

    print(login("admin", "123456"))
